/**
 * 
 */
package com.uit.project.bustrip.dao;

import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
import com.uit.project.bustrip.daointerface.UserDao;
import com.uit.project.bustrip.database.DBHelper;
import com.uit.project.bustrip.entity.User;
/**
 * @author 
 *
 */
public class UserDaoImpl extends BaseDaoImpl<User, Integer> implements UserDao {

	public UserDaoImpl(){
		super();
	}
	public UserDaoImpl(DBHelper db) {
		super(db);
	}
	@Override
	public User getFromJSON(JSONObject json) {
		try {
			User item = new User();
			item.id = json.getInt("id");
			item.code = json.getString("code");
			item.username = json.getString("username");
			item.account = json.getString("account");
			item.password = json.getString("password");
			item.numberphone = json.getString("numberphone");
			item.address = json.getString("address");
			item.email = json.getString("email");
			item.image = json.getString("image");
			item.company = json.getInt("company");
			item.userpower = json.getInt("userpower");
			item.status = json.getInt("status");
			return item;
		} catch (JSONException e) {
			Log.i("UserDaoImpl",e.getMessage());
			return null;
		}
	}
}
